fix bug in ref
update according Christof's comment