handle local and remote files