add helper for controllers and refactor some controller logic into this