clean code and add documentation