fixed bug with the repaint method