 
         # Check if already use
         if no_error is true
-            if @model instanceof models.Table
+            if @item_type == "table"
                 query = r.db(system_db).table('table_config').get(@model.get('id')).update
                     name: @formdata.new_name
-            else if @model instanceof model.Database
+            else if @item_type == "database"
                 query = r.db(system_db).table('db_config').get(@model.get('id')).update
                     name: @formdata.new_name
-            else if @model instanceof model.Server
+            else if @item_type == "server"
                 query = r.db(system_db).table('server_config').get(@model.get('id')).update
                     name: @formdata.new_name
 

    error_template: require('../../handlebars/error_input.hbs')
    class: 'rename-item-modal'

    initialize: (model, options) =>
        super()
        if @model instanceof models.Table
            @item_type = 'table'
        else if @model instanceof models.Database
            @item_type = 'database'
        else if @model instanceof models.Server
            @item_type = 'server'

    render: ->
        super

        @$('#focus_new_name').focus()


    on_submit: =>
        super
        @old_name = @model.get('name')
        @formdata = util.form_data_as_object($('form', @$modal))
