modularize & cleanup