Refactor to controller plugin