preparation for algorithm rewrite