Moved menu generation logic out of controller into its own library