small bug fix in database code