Prevent 'undefined offset' errors