some refactoring, using mongoskin instead of native mongodb module.