fixed some out of bounds errors