Rewrote selection filter in order to handle sets and to fix the order
issue