added a repaint function