refactor done, TODO: add tests and start using to find more requirements (like reports etc)