modularize algorithms