refactored controller, model, and views