fixed unicode issue
refactored code