added comments

added comments and made code more readable