improved error handling, improved index structure