made some stuff shorter and added some comments