added profiling, and sped up the js