refactor to use pointers not lists