replaced global arrays with plain objects