I've fixed the indentation (bad paste, I suspect).  Broke down the handlers into individual methods