login redirect code simplified