Simplifying code using the valueOf(String) method