merged location filtering code with existing base