Fixed issue with looping