working version where the variable scope fixed for mongodb exists query.
documentation updated in litcoffe