Added conditional to check for null value of parentLocation