corrected the check if a value if at the boundary; previously it missed it