ref handling