Added error handling and removed data attribution in functions since we should deal exclusively with the structures since they are passed back and forth