move logic from view to matching controller