adds comments, changes code layout