change stncpy to memcpy to copy metadata