Taking a class more than once?

So here’s the complicated but not so complicated story:

I went through something where I didn’t go to class and got F’s in all my classes. Then next semester I withdrew halfway through cause the school was just not a good place for me. Now I’m at a community college and taling over the classes I failed. One class in particular is chem. So I have a F, then a W, and now I’m in the class and probably am going to get a low B. However, I really want an A but know I want get it for this class because I took it during the summer and we have two weeks. I’m still trying but my question is if I wanted to take it over again for the A would it look bad when I try to get into a good university if I took it 4 times (one F, one W, and now the B) ?
The school I want is highly competive so I need better grades to balance out that one horrible semester.

PS- i’ve done well otherwise mostly A’s and one B in all other courses I have taken.

Don’t touch that class anymore. What’s done is done. You passed it, move on. If you feel like you must redeem yourself, then talk the next level in that class. The more you retake a class, the worse it looks.

If you get a B in this class, you need to leave it behind. Do not retake it. If it is the case that chem is an important class for your goals (for example, you want to go to med school), then instead of retaking it after you get the B, instead, do as ConcernedRabbit suggested - take an additional class in that subject, beyond the pre-med requirements, and ace it on the first try. This will prove your mastery of the subject.

In fact, since you will have passed the class, your college won’t likely even let you retake it. And even if they did, your financial aid wouldn’t cover the retake, since you did pass the class.