Fixed plotting error when rep>2