words management algorithm