Broke apart into multiple functions for future extensibility