corrected the potential function