Clean this up further with a function.