Fix bug in expert function