Correct phase mod algo (add below-bounds check)