added mongodb check, applied some cleanups