modified source code (second function)