changed wait to sleep