Added java5 generics, changed iterations