Implement Viberti algorithm