Fix undefined offset Errors