moving code to find prompt pattern into _get_output method