Hash to_s refactoring