fixing redirect loop issue