The body of this function shares quite a bit of code with the function above.  Is it worth combining them, or extracting the common code?