break out functionality into a function and export it