fix typo in comments and improved examples for the foreach function