directorywatcher optimised and refactored