fix some bug, add isOutBoundary function