improved code for windows only