added memory profiling