added some comments just to explain how stuff works