centralize redirect logic