fixed the code lingering persistent connections on the database