refactor controller generator