mask function addes and some fixes.