refactor generic file client