fix index errors