refactor and DRY controllers