added compatibility with java 7 (re-wrote iteration for collections)