fix reverse() bug