error handling
fix index