Fixed ref bug