Fixed 'undefined offset' error.