While loop implementation