v0.3 Rewritten with potential function