fixed bug with id and index
added support for older documents