add filtering functionality to the index method