fix decoding problem with search patterns: it works for me but let me know if it creates problems in other scenarios