Refactoring to accept filter query without ajax too