Added square-type algo