Fix accessing undefined object