Instead of having two arrays and trying to keep them in sync, you could have 1 array of {path: ..., model: ...}. Wouldn't it be easier?