Trying to resolve memory error