Extract logic into its own method