adds comments, cleans up code