fixed the range loops