algorithm by Brian Swichkow - MythOS