added exception if mode is set in kwargs