Added pretection against corrupt files