This doesn't seem lke the right way to get this, can you explain (docstring!) what this function is supposed to be.