Code refactoring for FileMonitor demo