Issue on Filtering Elements by Multi Checkbox Groups

Issue on Filtering Elements by Multi Checkbox Groups

Can you please take a look at This Demo fiddle and let me know how to fix these two issues here

I am trying to create a simple filter ui using this code but I have two issue here

1- Filters by Color is not working if you start with them. They work if user first filters by Shape first .

2- on Filter by Shape if you select square it will filter the boxes correctly but if you unchecked thesquare it will remove all boxes (which is not correct it should display all boxes now)

Can you please let me know what I am doing wrong and how I can fix this?