Handle the empty collection

If you don't do this, then an empty collection triggers an out of bounds exception at line 1 of `replaceOrRegister`.