typographical error correction
remove global variable
FIX resource leak