cleanup the weirdo code it had before by using a block in a utility method