private function unique_groupname($name)
    {
        $checkname = $name;
        $num       = 2;
        $hit       = false;

        do {
            $sql_result = $this->db->query(
                "SELECT 1 FROM " . $this->db->table_name($this->db_groups, true).
                " WHERE `del` <> 1".
                    " AND `user_id` = ?".
                    " AND `name` = ?",
                $this->user_id,
                $checkname);

            // append number to make name unique
            if ($hit = $this->db->fetch_array($sql_result)) {
                $checkname = $name . ' ' . $num++;
            }
        }
        while ($hit);

        return $checkname;
    }