add comments, remove unnecessary code