rewrote code to not use the %>% operator