fixed hasfile method