Updated promises code