Minor nit.  It seems you could factor out a single function here and pass in the background color to set.