fix out of range exception