changes suggested from Rprof