Fixed ref before assignment