Updated code for promise resolution