Updated to allow then() to be called multiple times