split redirect to two functions