added commentaries to every function and changed the scripts to run on the cluster