updated to use r type