refactor for pg inherit support