added better https support