The code in this method could use some comments (or a method docstring) explaining its intent. It's a bit obscure.