avoid strlen usage in loop
fixed copying of the struct as it's not being modified

in the subsequent function call