Added the main functionality using pymongo