fixed 2 heap out of bounds errors