refactor to accept File object