Restructured logic to work on windows machines.