Move view logic to views