Organize filtering javascript into file