Fixed undefined offset bug