added profiling and timing