changed loop arrays back to static; cleaned up