adding squares and update function