put in some comments and did some performance tests