Refactored the Controllers and html templates to make them more maintainbale