Moved sleep statement to a place where it will no longer cause bug.