changed to use function