Check that location is not null before adding to substitutions