Fix wrong code and make work on windows