Split out for easier testing