WIP

- move some functions into helper funcs
- add platform independence