these two methods look almost identical, couldn't we generalize them a bit and say, pass in the regex and the name so it works for both cases?