Refactor filename scanner