added string duplication code