CHANGED:clean up code ,valid the reference;