refactor to use pointers on value arrays
merged