fix out of range error