A two-steps method to balance a square matrix