fix reverse array bug
pull from upstream