Uncomented algorithmic implementation of base logic