Check if this.classes exists

If the user is not connected to the database `this.classes` is undefined. Then an error is thrown: *Cannot read length of undefined*.