improve modal management