added rake task for scheduler and seperated out code for scheduling