Added third implementation that captures potentials into key value pairs first