fixed DB initialization and class separation for better code organization.