added rewind for matrix generation