added inheritance to handle $ref