Make view more generic, move logic to controller