added profiling code (comented out now)