replacing error prone implementation when getting parent locations
refactoring js