added some error checking for variables to prevent errors in the apache
logs