replaced strcpy by memcpy with length+1