factored Square code out into an object