intorduced a thenR and refactored the use of the then() method of promise