simplify visual mode code