Refactor code: extract classes
Add code comments