database setting correct id when reading