change contacts and functions to remove duplicate code