Change dialog box call and clean unused code