fixing match_at_most and deleting unused code