improve ref filtering