Added body of general potential function