adding schedule function (needs debugged)