solution to simple looping