added new comments to make code clearer