putting complexity in controller instead of view