misc algorithm implement