fixed a promise chaining error