Added isset checks for some vars