Refactored session function into union's 'before'