Conditionally run a task