remove unneeded array looping and variables. use reference instead.