added sleep and removed infinite loop