added before filter and viewing logic