added guard to check for parent id in invariants