Not tested solution to R