mproved support for occasions when number of items is unknown. Added test cases and documentation.