added response saving logic