change mask value to int
some more refactoring