implementing flow mask algorithm + test
impl position mask algo