Reorganized to work with mongo