- added comments and code cleanup