added routines for boundary current detection