refactor to save new pics in db