Fix undefined object error