reordered HTTPS check