Moved all functionality into the view