refactored entities, added collections and a way to output collection as a JSON