Cosmetically I'd move this down to where it's actually used (if other changes are necessary)