added namedFunc function and changed scan function