encapsulate controller to make less code