move view logic to controller