Cleaner repaint code