added pointer duplicating funciton