Trying to fix out of bounds exception