improve https handling