Implemented Iterative version as well