documentation

Added documentation + some changes in cpp file