refactor toString method