Fix logic error in my boundaryCheck function