return function vs class