Need help figuring out which is the correct way to write the sentence.

1. In the summer we were going to the beach, and had a flat tire.
2. In the summer, when we were going to the beach, we had a flat tire.

Thanks....

2. is correct.