refactored for modularization