added iterative reverse