less confusing file layout
fixed loops and moved spilt functions and changed vars