Refactor code for better view.