refactored dialog locking (still not working)