Revise the wrapper and r scripts