added some comments for improved readability