Fix type conversion bug