Fixed a bug where the repository would try to connect multiple times to the database