correct indexes and add ssl variable checks