Lucas' 2013 code