correctly find previous match