Update TaskScheduler.js

Clean up and make easier functions code