passing struct by reference instead of global struct variable