Refactor code so that common code in the view controllers is shared.