refactored nosql part