Move prefix_ptr to a higher scope