Commented code for ease of understanding.