added sleep function