modified to work properly on windows