formatting and commenting

commented everything and fixed some formatting