Modified to check for memory errors over all cases