fixed to write users to db