refactor model and controller template