Comments added to improve code understanding.