changed logic of redirect