Refactor inclusive scan code