rework mask handling to actually work