improved open dialog logic.