Break code into two functions.