refactored for cygwin/windows