add mongo extensions refactor some code