Added trapping potential code