removed while loop, added -lm