Implemented nested while wends