fix out of index errors