Code optimization for better readability. Tested output.