(WIP) working implementation. Untested on windows
working on both windows and mac