Added logic for redirect