clear up looping logic