write solution to db