Add check if 'tw' is defined on finishing do_post