Fix bug in mask