fixed it in the cases where there were multiple boundaries... Added better comments