updated scheduler to work correctly