made it more efficient busy wait by introducing sleep