only declare res once, and re-use it in more places