Add withSession function