Correcting a bug in the toString() method