move variable 'words' to global
merge redundant code
try add some information