fix redirect function. stop application after call redirect