fixed type checking in db