algorithm implement