refactoring, remove code from the view