fixed offboundary issue