Fix bug in painting contents