swatch: simplify code