Nice work using two functions.  This breaks out the code to make it more readable.