reduce some code complexity. create an internal function to handle splitting up types