begin modularize code