refactor file watching