added evaluation code and did some cleanup/rearranging