Update code to more efficient dplyr