fixed an issue when the scheduler is not the main db. Silly mistake. TY to @DeanK for pointing it out
reword fixing