Refactored code and updated to models, views and controllers