added isValidReference method