Prototyped Main R Function