Move sleep to common place
Reindent code