fixed error handling in models/index