implement square array rotation