improvement: redraw borders when it's necessary