added subquery to redirection