factorize response handlers