Fixed undefined offset error