refactor views and controllers