cleaned up indentation, added some comments