Fix for out of bounds read