Refactored funtions that print errors to instead store them for access later by the calling program