using memcpy for solution