have db writing, need to modularize all this