check if array keys are set

I was getting an error for non set array keys. A simple isset() check seems to fix the problem and the script otherwise seems to run as planned.