better rexp for function detection