Code for R - Contributed by Mario Tomasello
CT fixed bug with current_proc_id