added more comments, removed some code