db first iteration; need refactoring