refactor mongo cursor
cleaning whitespace and standardize sql