write to DB - with function to manipulate database