Added isset check for variables

Fixed script from throwing "Notice: Undefined index:" notices.