Optimized code and support input database info from parameter