source code reorganization for better modularization