broke out some functions for easier unit testing