Transform null cost into Infinity to improve perfomacce