code quality review, improuvements and commenting