Add doc in functions and clean code