sleep amount calculation should be done in finally for accuracy.