prettied up some code. added comments. put things in headers.