Updated Addboundary function.