added isset() to avoid "notice" php errors for undefined var