refactoring of file-mon module, split large function