improved down sized painting algorithm