correctly handle visual mode