fixed string copying
Fixing potential bugs