added profiling option and db indexing