preliminary version
todo:
- parenting
- code clean up
- validation of function