array index warning: convert from global variables to pointer params