Fix out of range error