refactoring of the contact to string function