Small optimization: ``if (is_number)`` appears to be the same code in every case. Can you put it outside?