improve wrapper.R to handle files too