refactoring, organization, and cleanup
fixed array reference conflicts