Six year old beagle who bites what should you do?

hey i know what your going through i have a 12 year old begal named holly and she used to bit and i know its hard to do but you have to get it out of this habbit and every time it bites you have to grab its mouth and smack it.