handle back to previous dialog and fix some bugs