move setTimeout to wait for promise resolution