refactored to separate Database and Colleciton class