added function that unifies position filtering
made position filter functions use common macro