fixed the boundary bug