updated functions to use pointer arguments