use scheduler instead of hand-rolled threading