Reduce code of toString method