added improved function for boundary current detection based on peak detection algorithm