added optional mode-parameter to constructor