fix undefined local variable or method `conn' issue