fixed undefined offset error