Refactor scheduler to use functions instead of views
remove debugging