added sleep function, to be tested