fix warning: reference to local variable 'potentials' returned