write redirecting logic into handlers