Gets stuck in loop