modified to work on Cygwin