added some comments for better readability