Improved code for better readability and metrics.