added some more comments, need to remove unnecessary functions