added parameter for filename

+ small fix with exceptions