moved mask flags to the detectWater function call from module level variables