Try and tidy up dialog JS issue ii