added some comments and moved stuff around