fixed BUG in extracting instance when comparing with patterns