fixing a bug when the result of then was returned from another then