refactoring function that returns structs to functions that return value via pointer in parameters