Named the return parameters and restructured the function a bit.