loops done, minor bugs