db writing working