Added R based preprocessing