Faster mask implementation