Replace deprecated toSource() with toString()