dynamic constructor working