fixing the loops