first version of the Spear Algorithm implementation