Moved some code from jade to controller/back-end