Moving some logic to the ui file