diff --git a/mongodb.js b/mongodb.js
index 783d98c786b2251bf5b77f379d3971ae7ec07e83..12594fef07de8219932c75fd842ef0fd0d72753b 100644
--- a/mongodb.js
+++ b/mongodb.js
@@ -1,15 +1,14 @@
 const mongoose = require('mongoose');
+require('dotenv').config(); 
 
-// Function to connect to MongoDB using Mongoose and create collections
-async function connectDB() {
+const connectDB = async () => {
   try {
-    // Connect using the MongoDB URI from environment variables
-    const conn = await mongoose.connect(process.env.MONGO_URI || "mongodb://127.0.0.1:27017/todo_app");
+    const conn = await mongoose.connect(process.env.MONGO_URI);
     console.log(`MongoDB connected: ${conn.connection.host}`);
   } catch (err) {
     console.error(`Error: ${err.message}`);
-    process.exit(1); // Exit the process with failure if the connection fails
+    process.exit(1);
   }
-}
+};
 
-module.exports = connectDB;
\ No newline at end of file
+module.exports = connectDB;