cleanup debugged

the index 0 size 0 bug removed. also cleanup changed to a public static
void function