split out functions for readability/computability