factored out helper functions into their own module