fixed infite loop (hopefully)