Commented code to provide clarity on the functionality.