Added a flatten to make controller methods more flexible