Minor improvements on filtering javascript