Code reorganization for better readability