Cleaning up code and adding post function to main view controller