Fixed two index out of range errors