I think this function needs a clearer name or docstring. I can't tell what its supposed to do.