refactored Array.reverse