fixed to remove out of bounds error