clean up code and made filter work