Changed name, added functions

I'm splitting out each action into its own function. This whole thing
should probably be OOP-ified..