adding optimization to stop at square (instead of all)
first example of java lambda