added comments and refactored the source code