almoust working version with mongodb backend