improve scheduler logic