finally fixed that undef. ref.