Changes:
Refactor to work in Mac

TODO
- test if still works in linux