correct handling of empty location, avoiding memory errors