Fix index errors