Try and tidy up dialog JS issue