refactored repaint events