changed some things to use java 8 stream, forEach, etc.