added comments for better understanding.