refactor of controllers and add mongodb