move view rendering logic to controller