I'll add a comment before this function to explain its semantics a little better.