added checking of file existance