Fix conversion logic