Reimplementing database with model