adapted to templating
modernized controller and menu functions