revol detection and out of bounds check