close #5: modified the redirect logic