Pretty sure this is right, but I didn't test it.