adding function for failure of promise