I think the code would be easier to follow if it followed the functional programming paradigm where it returns some value given some input.