move event handler code from view layer to controller layer