refactored electrode remapping code