It's not just lithium and none of this is as simple as you imagine it to be.
If you don't tell what you want to say, I'm pretty comfortable to keep assuming the details are all wrong. And yes, it's a simple algorithm. Yet it seems to work quite well.