refactored for MVC