Dealt with bug in R code + Revised comments in Query script