Improve sleep(); change rate_plan to rate_function