make schedule function idempotent