Would be great to move this to a separate class/method which could be unit tested

@schiesbn want me to take care of this?