improved scheduler logic