Replaced repeated code with navigateToView