Created switch function constructor to accomodate both sender and receiver calls