(fix) removes undefined promise from the chain and minor improvements