move business logic from view into controller