use mongodb to save state and use less memory