add comments and changs coding styles