refactor: adapt main code to refactoring database connnection