added extra isset checks to get rid of some php notices