refactor controllers and views