refactor the way to build the view