v3.1 - added 'before function'