This is a really long function.  Can you split it up?