complete functions for ex17 and switch to usleep