Just an idea: can we move this to an external helper class instead?