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