Don't repeat yourself.

Make name parsing a function.