Working correctly but needs to have variable sleep for thread sleep