# Copyright (c) 2017 The Regents of the University of Michigan.
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.

def rotate_digit (digit):
    if digit > 4:
        return (digit * 2) - 9

    else:
        return digit * 2

def get_check_digit (number = None):
    if number:
        return (9 * ((int(number) // 10) + rotate_digit(int(number) % 10))) % 10

    else:
        return None

@@ -172,16 +172,136 @@
 tails.%0A%0A
+def convert_into_luhn_checkable_int (number):%0A    if number:%0A        return int(number)%0A%0A    else:%0A        return None%0A%0A
 def rota
@@ -441,16 +441,70 @@
  None):%0A
+    number = convert_into_luhn_checkable_int(number)%0A%0A
     if n
@@ -500,38 +500,63 @@
 )%0A%0A    if number
+ is None
 :%0A    
+    return None%0A%0A
     return (9 * 
@@ -557,27 +557,22 @@
  (9 * ((
-int(
 number
-)
  // 10) 
@@ -586,27 +586,22 @@
 e_digit(
-int(
 number
-)
  %25 10)))
@@ -610,35 +610,4 @@
  10%0A
-%0A    else:%0A        return None%0A

Refactor into convert_into_luhn_checkable_int method