Fixed undefined object bug