US stock markets close midweek higher