initial files
handle negative values
simplify initial value management
reduce variable scope
use memoizer to speed up fuction