refact single number ii code