cleanup and fix on getting array