Fix invalid type conversion