refactor model and view