added separate function that deal with local pointers