writing and reading from database works