added comments,code formatted