missing a docstring, but this function is pretty self-explanatory anyway