rebased on dialog 0.3