updated code to be compatible with windows and *nix