Added ability to pass a function modularly.
Added square selection code.