Moving some logic out of main and into view