use nanosleep instead of usleep, ugaX11 calls msSleep instead of usleep