fixed database code.