r is working again; got rid of an unnecessary loop