add debug flag
avoid unnecessary redirect
simplify