fixed error check when running files