- Reorganize code and added comments