Move view logic out of event handling