moved some imperative code to more functional