Move code into check_all.R script