fixed ref bug