refactoring so as to avoid passing a painter