Refactered code for readability.