better use of $ref