refactoring, escape strings correctly