starts refactor and documentation
more refactor