reorganize algorithms