Modified the scheduler to make it a bit more robust