reorganize directory, modularize code