fix #4. had used global variable