use instantiation function
if judgement use function