yet more refactoring of controller