Implemented algorithm