add dialog hide function (not working correctly yet)