refactoring
fixed running errors on windows
fixed saving method using latin-1 encoding