Refactored to work on Windows