move app context ,add debug flag