Additions to controller, added a helper method to simplify controller.

Fixed a bug in controller.