Fixed type conversion bug