Fixed bug in repaint

Fixed bug in repaint