Declared all functions in the ViewController.m and cleaned up the code a bit.