Functions moved from controller to views