Moved query scheduling logic to "scheduler" module