make sure the repaint callback only happens once