Replace ifs with matches