Refactor for modularization