fixed bugs, added sleep_time, added timer