cleaned up the loop