fix undefined local variable