implemented promise within existing code