Updated to handle ssl