Did I do it right

I'm 17 with a toddler so I haven't actually experienced this with my own child or any other until today. My seven year old nephew lives with us (us being me my son my mom and my dad) My mom and dad took him in when he was two do to my sister not being able to give him the life she wanted him to have. Well today we were outside walking and he randomly said "Nigga" I looked at him and was like, what did you just say? He said it again. I explained to him not to say it again and that it's a bad word for his age. I did tell him that I was telling maw maw though (my mom) because she can explain to him why he shouldn't say it better than I can, well about an hour and half later he says the word "Pussy" I asked him where he learned that, he said that my step nephew (he's five) taught him the word and told him it wasn't bad. It doesn't surprise me because that kid does learn a lot of things like that from places that he goes too. I told him that it was in fact a bad word for his age, and not to say any other word that his cousin tries to tell him about, I did tell my mom, I told her not to get on to him because I did explain to him what the words were an everything but I wanted her to explain it further, in case I missed anything. I was wondering if I did it right is all. I didn't want to scream at him and make him think it was SUPER bad because yes it's bad but not enough to scream at him or spank him or something. He does know not to say it again.