fixed local variable 'records' referenced before assignment bug