wrap global arrays in getter functions
better error handling