I wonder if this could be tidied a little bit, e.g. replace `else if` with `else`, and use `{ if (isNaN(id)) return; }`?