I am confused how this code works. This `resolve` is for the returned promise right? So won't this just always resolve the returned promise with the first promise in the array?