Documented code with comments

May take a while to run with large dataset