Carried out number logic into a separate function