added support for multiple databases
Updated to support multiple databases