refactor to use control.applicative where appropriate