fixed issues with strings, code refactoring

fixed issues with strings, code refactoring
Improve efficiency