Implemented Looping functionality