ensure sleep() in main() is not given a negative value