rewrote everything with respect to java 8
changed some List parameters to Collection