refactored to be more consistent with MVC