Was I right to give him another chance?

I'm 17 & my boyfriend is 18, he just recently went to college. While he first was there everything was going great, at the time we were dating for 4 months, and I didn't have to worry about anything. Then one weekend he told me he thought we needed a break, said he was stressed and he felt weird about us. We worked through it though & after that we were fine again. Until one night somehow my ex boyfriend came up & he got really mad at the fact that I had sex before him when he was a virgin & never had sex before me. He literally broke up with me for it and wrote me this 2600 word letter about how immature I am and how that one thing I did was a fatal flaw and how I offer him nothing, a really hurtful letter. A week later he came home from school and apologized to me, wanted me back, said it took the pain of breaking up to realize how dumb he was being. I gave him another chance but was i dumb for doing that? He judged me on something I couldn't control, I didn't even know him then and he put me through so much pain. Right now we are perfectly fine though, nothing's been weird. He's like my best friend and makes me so so happy, I can truly be myself with him all the time. But should I still be worried that it can happen again in the future? HELP!!