fix out of bounds access