Started implementing algorithm