add R middleware support