Updated working version of the first draft for random forest algorithm