Updated code to use Pointers.