changed to usleep for Mac/Linux