added profiling - still to attempt speedup