Needs generalizing into a function or class.