extracted functionality to controller