Move the complex COTS filter logic to controller, from HTML.