fixing thread sleep