inserted some comments and implemented comparison method