updated logic of redirect on needing authentication