Refactor location helper

@christopheschwyzer please review