Updated the code to work in both linux and windows;