better location query mechanism (including debug for now)