better indentation and better logging
more refactor and decoupling