added support for mongoengine with the updated code