Fixing bug lastMatch