First implementation of db writes